package bairui.international.service.impl;

import bairui.international.model.domain.jpa.TB_BranchCompanyWithdrawOrder;
import bairui.international.service.Service_BranchCompanyWithdrawOrder_Generate;
import org.springframework.stereotype.Service;
import bairui.international.dao.jpa.Repository_BranchCompanyWithdrawOrder;

/**
 *
 */
@Service
public class Service_BranchCompanyWithdrawOrderImpl_Generate
	implements Service_BranchCompanyWithdrawOrder_Generate
{

	
	@org.springframework.beans.factory.annotation.Autowired
	private Repository_BranchCompanyWithdrawOrder dao;

	@org.springframework.beans.factory.annotation.Autowired
	private bairui.international.service.Service_BranchCompanyWithdrawVerifyRecord service_BranchCompanyWithdrawVerifyRecord;

	@org.springframework.beans.factory.annotation.Autowired
	private bairui.international.service.Service_BranchCompanyMoneyRecord service_BranchCompanyMoneyRecord;



	
	
	
	/**
	 * deleteById
	 */
	public void deleteById(
		@com.sh_lianjing.annotation.ParameterName("id") @lombok.NonNull Long id
	) throws Exception {
		TB_BranchCompanyWithdrawOrder bean = getDao().findById(id).get();
		// branchCompanyWithdrawVerifyRecords
		java.util.List<bairui.international.model.domain.jpa.TB_BranchCompanyWithdrawVerifyRecord> branchCompanyWithdrawVerifyRecords = service_BranchCompanyWithdrawVerifyRecord.page(it->it.branchCompanyWithdrawOrder.eq(bean), org.springframework.data.domain.PageRequest.of(0, 3)).getContent();
		
		if(!branchCompanyWithdrawVerifyRecords.isEmpty()){
			String str = "("+bean.toString()+")正在被("+bairui.international.model.domain.jpa.TTB_BranchCompanyWithdrawVerifyRecord.Comment+":[";
			boolean startFlag = true;
			for(bairui.international.model.domain.jpa.TB_BranchCompanyWithdrawVerifyRecord item : branchCompanyWithdrawVerifyRecords){
				if(!startFlag){
					str += ", ";
				}
				startFlag = false;
				str += item.toString();
			}
			str += ", ...])使用";
			throw new com.lianjing.sh.validate.spring.exception.ValidateObjectException("", "branchCompanyWithdrawVerifyRecords", str);
		}
		// branchCompanyMoneyRecords
		java.util.List<bairui.international.model.domain.jpa.TB_BranchCompanyMoneyRecord> branchCompanyMoneyRecords = service_BranchCompanyMoneyRecord.page(it->it.branchCompanyWithdrawOrder.eq(bean), org.springframework.data.domain.PageRequest.of(0, 3)).getContent();
		
		if(!branchCompanyMoneyRecords.isEmpty()){
			String str = "("+bean.toString()+")正在被("+bairui.international.model.domain.jpa.TTB_BranchCompanyMoneyRecord.Comment+":[";
			boolean startFlag = true;
			for(bairui.international.model.domain.jpa.TB_BranchCompanyMoneyRecord item : branchCompanyMoneyRecords){
				if(!startFlag){
					str += ", ";
				}
				startFlag = false;
				str += item.toString();
			}
			str += ", ...])使用";
			throw new com.lianjing.sh.validate.spring.exception.ValidateObjectException("", "branchCompanyMoneyRecords", str);
		}
		getDao().deleteById(id);
	}
	/**
	 * findDeleteById
	 */
	public TB_BranchCompanyWithdrawOrder findDeleteById(
		@com.sh_lianjing.annotation.ParameterName("id") @lombok.NonNull Long id
	) throws Exception {
		TB_BranchCompanyWithdrawOrder bean = getDao().findById(id).get();
		// branchCompanyWithdrawVerifyRecords
		java.util.List<bairui.international.model.domain.jpa.TB_BranchCompanyWithdrawVerifyRecord> branchCompanyWithdrawVerifyRecords = service_BranchCompanyWithdrawVerifyRecord.page(it->it.branchCompanyWithdrawOrder.eq(bean), org.springframework.data.domain.PageRequest.of(0, 3)).getContent();
		
		if(!branchCompanyWithdrawVerifyRecords.isEmpty()){
			String str = "("+bean.toString()+")正在被("+bairui.international.model.domain.jpa.TTB_BranchCompanyWithdrawVerifyRecord.Comment+":[";
			boolean startFlag = true;
			for(bairui.international.model.domain.jpa.TB_BranchCompanyWithdrawVerifyRecord item : branchCompanyWithdrawVerifyRecords){
				if(!startFlag){
					str += ", ";
				}
				startFlag = false;
				str += item.toString();
			}
			str += ", ...])使用";
			throw new com.lianjing.sh.validate.spring.exception.ValidateObjectException("", "branchCompanyWithdrawVerifyRecords", str);
		}
		// branchCompanyMoneyRecords
		java.util.List<bairui.international.model.domain.jpa.TB_BranchCompanyMoneyRecord> branchCompanyMoneyRecords = service_BranchCompanyMoneyRecord.page(it->it.branchCompanyWithdrawOrder.eq(bean), org.springframework.data.domain.PageRequest.of(0, 3)).getContent();
		
		if(!branchCompanyMoneyRecords.isEmpty()){
			String str = "("+bean.toString()+")正在被("+bairui.international.model.domain.jpa.TTB_BranchCompanyMoneyRecord.Comment+":[";
			boolean startFlag = true;
			for(bairui.international.model.domain.jpa.TB_BranchCompanyMoneyRecord item : branchCompanyMoneyRecords){
				if(!startFlag){
					str += ", ";
				}
				startFlag = false;
				str += item.toString();
			}
			str += ", ...])使用";
			throw new com.lianjing.sh.validate.spring.exception.ValidateObjectException("", "branchCompanyMoneyRecords", str);
		}
		getDao().deleteById(id);
		return bean;
	}
	/**
	 * deleteByIds
	 */
	public void deleteByIds(
		@com.sh_lianjing.annotation.ParameterName("ids") @lombok.NonNull Long ... ids
	) throws Exception {
		deleteByIds(java.util.Arrays.asList(ids));
	}
	
	/**
	 * deleteByIds
	 */
	public void deleteByIds(
		@com.sh_lianjing.annotation.ParameterName("ids") @lombok.NonNull java.util.List<Long> ids
	) throws Exception {
		for(Long id : ids){
			deleteById(id);
		}
	}
		






	/**
	 * getDao()
	 */
	public bairui.international.dao.jpa.Repository_BranchCompanyWithdrawOrder getDao() {
		return dao;
	}

}
